1. Field of the Invention
The present invention relates to a method for displaying a resized window, and more particularly, to a method which can prevent window flicker when displaying a resized window.
2. Description of the Prior Art
For window scaling, some operating systems take one point of the window as a reference point to draw the scaled window. Suppose that the operating system takes the top-left point as the reference point. If a user scales the window by expanding the top or left side, it is obvious that the window and the content of such would flicker. In this case, the operating system draws the scaled window based on the reference point (the top-left point of the original window), and then moves the top-right point of the scaled window to the top-right point of the original window, so that window scaling is achieved. However, when moving the scaled window, window flicker occurs. This phenomenon is more pronounced when scaling a window containing video.
Please refer to FIGS. 1 and 2. FIG. 1 is a diagram of moving a first window 10 according to the prior art. FIG. 2 is a diagram of scaling the first window 10 to become a second window 12 according to the prior art. The first window 10 has a first size, and is located at a position corresponding to a first reference point (the top-left point) P1 before being moved or scaled. As shown in FIG. 1, when the first window 10 is moved, the first window 10 is re-drawn at a new position (shown in dashed line), remaining at the same window size. In FIG. 2, the first window 10 is scaled to become a second window 12 having a second size (shown in dashed line). The second window 12 (shown in dashed line) is drawn according the first reference point P1. Then, the top-right point of the dashed line area is moved to the top-right point of the first window 10, taken as a second reference point P2, so that the scaling process is achieved (as shown by the second window 12 (in solid line. Please refer to FIG. 3, which is a flowchart of adjusting the first window according to the prior art.
Step 100: Start.
Step 102: A message queue receives a message (first message).
Step 104: Determine whether the message includes a request for adjusting the first window 10. If so, step 106 is entered. Otherwise, step 124 is entered.
Step 106: The information for an adjustment of the first window 10 is obtained from the message.
Step 108: Determine whether the information obtained from step 106 includes a command for scaling the first window 10. If so, step 114 is entered; otherwise, step 110 is entered.
Step 110: A new position of the first window 10 is obtained according to the information obtained in step 106.
Step 112: As shown in FIG. 1, the first window 10 is re-drawn at the new position so that the first window 10 is moved from the original position to the new position, and then step 124 is entered.
Step 114: As shown in FIG. 2, the first window 10 having the first size is scaled to become the second window 12 having the second size according to the information obtained in step 106.
Step 116: As shown by the dashed line area of FIG. 2, the second window 12 having the second size is drawn at the position corresponding to the first reference point P1.
Step 118: The message queue receives a next message (a second message).
Step 120: The information for the adjustment of the first window 10 is obtained from the next message received in step 118.
Step 122: As shown in FIG. 2, the second window 12 having the second size is displayed at the position corresponding to the second reference point P2 according to the information of step 120, such that the second window 12 is moved from the position corresponding to the first reference point P1 (the dashed line area) to the position corresponding to the second reference point P2.
Step 124: End.
From the above steps, when the user wants to move the window but not to scale it, the operating system processes the window movement using a message. However, when the user wants to scale the window, the operating system processes the scaling using two messages instead. That is, when the user only moves the window, the operating system obtains the new position where the first window is moved to according the information of step 106, and draws the first window 10 at the new position, accomplishing the movement. Nevertheless, when the user wants to scale the window in steps 114 and 116, the first window 10 having the first size is scaled to become the second window 12 having the second size, and the second window 12 is drawn according to the first reference point P1. In other words, if scaling the first window 10 by expanding the left side, the second window 12 is drawn in the dashed line area in FIG. 2 (the position corresponding to the first reference point P1). Then, as mentioned in steps 118 and 122, the second window 12 is displayed at the position corresponding to the second reference point P2 according to a second received message, such that the second window 12 is moved from the dashed line area (the position corresponding to the first reference point P1) to the position corresponding to the second reference point P2. In short, when the user wants to scale the window, the resized window (the second window 12) is displayed at the original position (the position corresponding to the first reference point P1), and then moved to the new position (the position corresponding to the second reference point P2). Therefore, when expanding the left side of the window, the window is expanded rightward and then moved leftward. Or, when expanding the top of the window, the window is expanded downward and then moved upward. These result in window flicker, especially when scaling a window contacting video playback.